package cn.dansj.common.utils.jdbc;

import cn.dansj.common.utils.transfer.DefaultMethods;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class ParseResult extends DefaultMethods {
    private final List<String> result = new ArrayList<>();

    public ParseResult(List<String> result) {
        if (result != null) {
            this.result.addAll(result);
        }
    }

    public static ParseResult Empty = new ParseResult(null);

    public List<String> getResult() {
        return result;
    }

    public boolean isEmpty() {
        return result.isEmpty();
    }

    public boolean hasDDL() {
        return result.stream().anyMatch(DBUtils::isDDL);
    }

    public boolean hasDQL() {
        return result.stream().anyMatch(DBUtils::isDQL);
    }

    public List<String> getDDL() {
        return result.stream().filter(DBUtils::isDDL).collect(Collectors.toList());
    }

    public List<String> getDQL() {
        return result.stream().filter(DBUtils::isDQL).collect(Collectors.toList());
    }
}
